from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Jellyfish(Item):
    def __init__(self):
        Item.__init__(self, "jellyfish")    # do basic initialization for every item
        self.is_lighting = False
        
        # build list of actions
        self.add_action(UseJellyfish)
        self.add_action(StopUsingJellyfish)
    
    def get_description(self):
        if self.is_lighting:
            return "Jellyfish (on your arm)"
        else:
            return "Jellyfish"
# define actions for this item

class UseJellyfish(Action):
    def __init__(self):
        Action.__init__(self, "use_jellyfish")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use Jellyfish"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # enabled only if knife is in.
    def is_enabled(self):
        if self.item.is_lighting:
            return False
        else:
            return True
        
    # get knife out and add cutscene
    def do_action(self,game,room,request):
        self.item.is_lighting = True
        set_cutscene("You use the jellyfish and now you can see.")
        return
    
class StopUsingJellyfish(Action):
    def __init__(self):
        Action.__init__(self, "stop_using_jellyfish")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Stop Using Jellyfish"

    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"    
    
    # enabled only if lamp is out.
    def is_enabled(self):
        if self.item.is_lighting:
            return True
        else:
            return False
        
    # get knife in and add cutscene
    def do_action(self,game,room,request):
        self.item.is_lighting = False
        set_cutscene("You take the jellyfish away.")
        return
    
#def do_action(self,game,room,request):
#        if self.item.has_oil:
#            if room.get_id() == 'basement':
#                if room.lock_rusty:
#                    set_cutscene("You squirt some oil on the lock on the large door.")
#                    self.item.has_oil = False
#                    room.lock_rusty = False
#            else:
#                set_cutscene("You squeeze the oil can and a jet of oil streams on to the floor.  The oil can is now empty.  There is a small pool of oil on the floor.")
#                self.item.has_oil = False
#        else:
#            set_cutscene("You squeeze the oil can, but it is empty.")
#        return